package com.ihr360.payroll.service.salarytasklet.expr.engine;

import com.ihr360.expr.core.Expr;

import java.util.HashMap;
import java.util.Map;

/**
 * @author davidwei
 */
public class PersonVariableProvider {
    private Map<String, Expr> personalVariables = new HashMap<>();

    public void addVaribale(String variableId, Expr expr) {
        if (expr == null) {
            personalVariables.remove(variableId);
        } else {
            personalVariables.put(variableId, expr);
        }
    }

    public void removeVaribale(String variableId) {
        personalVariables.remove(variableId);
    }


    public Expr getVariable(String variableId) {
        return personalVariables.get(variableId);
    }

    public Map<String, Expr> getAllVariables(){
        return personalVariables;
    }

    public void clear() {
        this.personalVariables.clear();
    }
}